function Y = deploy_batch(X, up_scale)

[hei, wid, num] = size(X);
if num == 1
    Y = SRCNN.deploy(X, up_scale);
    return
end

%%
model = ['x' num2str(up_scale) '.mat'];
st = importdata(fullfile(SRCNN.path, '9-5-5(ImageNet)', model));

%% load CNN model parameters
[conv1_patchsize2, conv1_filters] = size(st.weights_conv1);
conv1_patchsize = sqrt(conv1_patchsize2);

[conv2_channels, conv2_patchsize2, conv2_filters] = size(st.weights_conv2);
conv2_patchsize = sqrt(conv2_patchsize2);

[conv3_channels, conv3_patchsize2] = size(st.weights_conv3);
conv3_patchsize = sqrt(conv3_patchsize2);

%% conv1
st.weights_conv1 = reshape(st.weights_conv1, conv1_patchsize, conv1_patchsize, conv1_filters);
conv1_data = zeros(hei, wid, num, conv1_filters);
for i = 1 : conv1_filters
    conv1_data(:,:,:,i) = imfilter(X, st.weights_conv1(:,:,i), 'same', 'replicate');
    conv1_data(:,:,:,i) = max(conv1_data(:,:,:,i) + st.biases_conv1(i), 0);
end

%% conv2
conv2_data = zeros(hei, wid, num, conv2_filters);
for i = 1 : conv2_filters
    for j = 1 : conv2_channels
        conv2_subfilter = reshape(st.weights_conv2(j,:,i), conv2_patchsize, conv2_patchsize);
        conv2_data(:,:,:,i) = conv2_data(:,:,:,i) + imfilter(conv1_data(:,:,:,j), conv2_subfilter, 'same', 'replicate');
    end
    conv2_data(:,:,:,i) = max(conv2_data(:,:,:,i) + st.biases_conv2(i), 0);
end

%% conv3
conv3_data = zeros(hei, wid, num);
for i = 1 : conv3_channels
    conv3_subfilter = reshape(st.weights_conv3(i,:), conv3_patchsize, conv3_patchsize);
    conv3_data = conv3_data + imfilter(conv2_data(:,:,:,i), conv3_subfilter, 'same', 'replicate');
end

%% SRCNN reconstruction
Y = conv3_data + st.biases_conv3;
